package com.boot.controller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author
 * @date 2025-07-29
 * @Description
 */
//如果没有指定包路径， 会基于当前配置类所在包去扫描
//相当于 @ComponentScan("com.boot")
@ComponentScan
@EnableAutoConfiguration
public class MainApplication {
    public static void main(String[] args) {
        //启动spring框架，必须指定一个配置 （配置类）
        ApplicationContext run = SpringApplication.run(MainApplication.class);

        UserController userController = (UserController) run.getBean("userController");
        userController.test();

        System.out.println("------------------");


        UserService userService = (UserService) run.getBean("userService");
        userService.test();

        System.out.println("------------------");

        UserDao userDao = (UserDao) run.getBean("userDao");
        userDao.test();

        System.out.println("----------------");

        System.out.printf("[%s]%n","dmc");
        System.out.printf("[%10s]%n","dmc");
        System.out.printf("[%-10s]%n","dmc");
        System.out.printf("\033[36m[%-10s]%n\033[30m","dmc");


        for(int i=0;i<100;i++){
            userController.test();
        }
    }
}
